#include <iostream>  
#include <vector>  
  
using namespace std;  
  
int sumOddLengthSubarrays(vector<int>& arr) {  
    int n = arr.size();  
    int ans = 0;  
    for (int i = 0; i < n; i++) {  
        int prefixSum = 0;  
        for (int j = i; j < n; j += 2) {  
            prefixSum += arr[j];  
            ans += prefixSum;  
        }  
    }  
    return ans;  
}  
  
int main() {  
    vector<int> arr = {1, 4, 2, 5, 3};  
    int ans = sumOddLengthSubarrays(arr);  
    cout << "所有奇数长度的子数组的和为：" << ans << endl;  
    return 0;  
}
